#include <bits/stdc++.h>

using namespace std;
map<int,int>o,p;
int main() {
	int t;
	cin >> t;
	while (t--) {
		int n;
		cin >> n;
		o.clear();
		p.clear();
		string s;
		cin >> s;
		int x = 0, y = 0;
		int f = 1;
		for (int i = 0; i < (int)s.length(); i ++) {
			if(s[i] == 'a') x++;
			else y++;
			if(x == y) {
				cout << 1 << " " << i + 1<< endl;
				f = 0;
				break;
			}
			else if(p[y - x]){
			//cout << y << x << endl;
		    	cout << (i + 1)-(y - o[y - x]) * 2 + 1 << " "<< i + 1 << endl;
				//cout << i + 1 <<" "<< i + 1 -(y - o[y - x] - 1)<< endl;
				f = 0;
				break;
			}
			if(!p[y - x]) o[y - x] = y;
			p[y - x] = 1;
		}
		if (f) puts("-1 -1");
	}
}
